package com.heima.kafka.listener;

import com.heima.kafka.pojos.User;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class MsgListener {

    /**
     * 监听topic-string主题
     */
    @KafkaListener(topics = "topic-string")
    public void onMessage(String message) {
        System.out.println("接收到消息：" + message);
    }

    /**
     * 监听topic-object主题
     */
    @KafkaListener(topics = "topic-object")
    public void onMessage(User user) {
        System.out.println("接收到消息：" + user);
    }
}
